BablPixelFormat cleanup
authorØyvind Kolås <ok@src.gnome.org>
Mon, 22 Aug 2005 12:31:08 +0000 (12:31 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Mon, 22 Aug 2005 12:31:08 +0000 (12:31 +0000)
ChangeLog
babl/babl-classes.h
babl/babl-fish.c
babl/babl-format.c
babl/babl-pixel-format.c
tests/babl-html-dump.c

index d1e782103f84527dcf5566cc0f106a30fc6a8d31..355055597c37274e3db1f9baca0efc6a3ac6ba5d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-08-22  Øyvind Kolås  <pippin@gimp.org>
+
+       * babl/babl-classes.h: (BabPixelFormat): only a single BablModel.
+       * babl/babl-fish.h,
+       * babl/babl-pixel-format.h,
+       * tests/babl-html-dump.c: accomodate change.
+
 2005-08-21  Øyvind Kolås  <pippin@gimp.org>
 
        * docs/.cvsignore: added Makefile and Makefile.in
index 2ac7b94ec185c22e937cc1fa1c2f21f162a5c9ee..d8342682fcb0d61c74c8ea77ee7af777ce01ebf9 100644 (file)
@@ -173,7 +173,7 @@ typedef struct
   BablConversion **to;   /*< NULL terminated list of conversions to class   */
   int              bands;
   int              planar;
-  BablModel      **model;
+  BablModel       *model;
   BablComponent  **component;
   BablType       **type;
   BablSampling   **sampling;
index fdb06a208a8bc71c636ba0a26119814820c2806c..3be6b33d58cc6fc6f79647b860cd60ab167ed039 100644 (file)
@@ -146,14 +146,14 @@ babl_fish_reference_new (Babl *source,
 
       babl->reference_fish.model_to_rgba =
         babl_conversion_find (
-            source->pixel_format.model[0],
+            source->pixel_format.model,
             babl_model_id (BABL_RGBA)
         );
 
       babl->reference_fish.rgba_to_model =
         babl_conversion_find (
             babl_model_id (BABL_RGBA),
-            destination->pixel_format.model[0]
+            destination->pixel_format.model
         );
 
       babl->reference_fish.double_to_type =
@@ -169,14 +169,14 @@ babl_fish_reference_new (Babl *source,
 
       babl->reference_fish.model_to_rgba =
         babl_conversion_find (
-            source->pixel_format.model[0],
+            source->pixel_format.model,
             babl_model_id (BABL_RGBA)
         );
 
       babl->reference_fish.rgba_to_model =
         babl_conversion_find (
             babl_model_id (BABL_RGBA),
-            destination->pixel_format.model[0]
+            destination->pixel_format.model
         );
 
       babl->reference_fish.double_to_type =
@@ -256,7 +256,7 @@ babl_fish_process (Babl *babl,
 
   /* calculate planar representation of fooA, and fooB */
 
-  imageA = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.source)) -> pixel_format.model[0]));
+  imageA = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.source)) -> pixel_format.model));
   imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA));
   /* transform fooA into fooB fooB is rgba double */
 
@@ -275,7 +275,7 @@ babl_fish_process (Babl *babl,
   /* transform fooB into fooC fooC is ???? double */
 
   imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA));
-  imageC = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.destination))->pixel_format.model[0]));
+  imageC = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.destination))->pixel_format.model));
 
   babl->reference_fish.rgba_to_model->function.planar(
           imageB->image.bands, 
index a64349ac68648c64f7dd21dc3ab33bf5db6a3b48..d10fb5a95ec22c9359a7ec613fb0db0f3cdfe653 100644 (file)
@@ -44,7 +44,7 @@ pixel_format_new (const char     *name,
                   int             id,
                   int             planar,
                   int             bands,
-                  BablModel     **model,
+                  BablModel      *model,
                   BablComponent **component,
                   BablSampling  **sampling,
                   BablType      **type)
@@ -55,15 +55,13 @@ pixel_format_new (const char     *name,
   /* allocate all memory in one chunk */
   babl  = babl_calloc (sizeof (BablPixelFormat) +
                        strlen (name) + 1 +
-                       sizeof (BablModel*)     * (bands+1) +
                        sizeof (BablComponent*) * (bands+1) +
                        sizeof (BablSampling*)  * (bands+1) +
                        sizeof (BablType*)      * (bands+1) +
                        sizeof (int)            * (bands+1) +
                        sizeof (int)            * (bands+1),1);
 
-  babl->pixel_format.model     = ((void *)babl) + sizeof (BablPixelFormat);
-  babl->pixel_format.component = ((void *)babl->pixel_format.model)     + sizeof (BablModel*) * (bands+1);
+  babl->pixel_format.component = ((void *)babl) + sizeof (BablPixelFormat);
   babl->pixel_format.type      = ((void *)babl->pixel_format.component) + sizeof (BablComponent*) * (bands+1);
   babl->pixel_format.sampling  = ((void *)babl->pixel_format.type)      + sizeof (BablType*) * (bands+1);
   babl->instance.name          = ((void *)babl->pixel_format.sampling)  + sizeof (BablSampling*) * (bands+1);
@@ -72,17 +70,16 @@ pixel_format_new (const char     *name,
   babl->instance.id   = id;
   strcpy (babl->instance.name, name);
 
-  babl->pixel_format.bands    = bands;
-  babl->pixel_format.planar   = planar;
+  babl->pixel_format.model  = model;
+  babl->pixel_format.bands  = bands;
+  babl->pixel_format.planar = planar;
 
   for (band=0; band < bands; band++)
     {
-      babl->pixel_format.model[band] = model[band];
       babl->pixel_format.component[band] = component[band];
       babl->pixel_format.type[band] = type[band];
       babl->pixel_format.sampling[band] = sampling[band];
     }
-  babl->pixel_format.model[band] = NULL;
   babl->pixel_format.component[band] = NULL;
   babl->pixel_format.type[band]      = NULL;
   babl->pixel_format.sampling[band]  = NULL;
@@ -99,14 +96,13 @@ babl_pixel_format_new (const char *name,
   int              id     = 0;
   int              planar = 0;
   int              bands  = 0;
-  BablModel       *model     [BABL_MAX_BANDS];
+  BablModel       *model  = NULL;
   BablComponent   *component [BABL_MAX_BANDS];
   BablSampling    *sampling  [BABL_MAX_BANDS];
   BablType        *type      [BABL_MAX_BANDS];
 
   BablSampling    *current_sampling = (BablSampling*) babl_sampling (1,1);
   BablType        *current_type     = (BablType*)     babl_type_id (BABL_U8);
-  BablModel       *current_model    = NULL;
   const char      *arg              = name;
 
   va_start (varg, name);
@@ -129,12 +125,11 @@ babl_pixel_format_new (const char *name,
                 current_type = (BablType*) babl;
                 break;
               case BABL_COMPONENT:
-                if (!current_model)
+                if (!model)
                   {
                     babl_log ("%s(): no model specified before component %s",
                               __FUNCTION__, babl->instance.name);
                   }
-                model     [bands] = current_model;
                 component [bands] = (BablComponent*) babl;
                 type      [bands] = current_type;
                 sampling  [bands] = current_sampling;
@@ -150,7 +145,12 @@ babl_pixel_format_new (const char *name,
                   current_sampling = (BablSampling*)arg;
                   break;
               case BABL_MODEL:
-                  current_model = (BablModel*)arg;
+                  if (model)
+                    {
+                    babl_log ("%s(%s): model %s already requested",
+                     __FUNCTION__, babl->instance.name, model->instance.name);
+                    }
+                  model = (BablModel*)arg;
                   break;
               case BABL_INSTANCE:
               case BABL_PIXEL_FORMAT:
@@ -198,9 +198,8 @@ babl_pixel_format_new (const char *name,
 
 
   babl = pixel_format_new (name, id,
-                           planar,
-                           bands,
-                           model, component, sampling, type);
+                           planar, bands, model,
+                           component, sampling, type);
 
   
   if (db_insert (babl) == babl)
index a64349ac68648c64f7dd21dc3ab33bf5db6a3b48..d10fb5a95ec22c9359a7ec613fb0db0f3cdfe653 100644 (file)
@@ -44,7 +44,7 @@ pixel_format_new (const char     *name,
                   int             id,
                   int             planar,
                   int             bands,
-                  BablModel     **model,
+                  BablModel      *model,
                   BablComponent **component,
                   BablSampling  **sampling,
                   BablType      **type)
@@ -55,15 +55,13 @@ pixel_format_new (const char     *name,
   /* allocate all memory in one chunk */
   babl  = babl_calloc (sizeof (BablPixelFormat) +
                        strlen (name) + 1 +
-                       sizeof (BablModel*)     * (bands+1) +
                        sizeof (BablComponent*) * (bands+1) +
                        sizeof (BablSampling*)  * (bands+1) +
                        sizeof (BablType*)      * (bands+1) +
                        sizeof (int)            * (bands+1) +
                        sizeof (int)            * (bands+1),1);
 
-  babl->pixel_format.model     = ((void *)babl) + sizeof (BablPixelFormat);
-  babl->pixel_format.component = ((void *)babl->pixel_format.model)     + sizeof (BablModel*) * (bands+1);
+  babl->pixel_format.component = ((void *)babl) + sizeof (BablPixelFormat);
   babl->pixel_format.type      = ((void *)babl->pixel_format.component) + sizeof (BablComponent*) * (bands+1);
   babl->pixel_format.sampling  = ((void *)babl->pixel_format.type)      + sizeof (BablType*) * (bands+1);
   babl->instance.name          = ((void *)babl->pixel_format.sampling)  + sizeof (BablSampling*) * (bands+1);
@@ -72,17 +70,16 @@ pixel_format_new (const char     *name,
   babl->instance.id   = id;
   strcpy (babl->instance.name, name);
 
-  babl->pixel_format.bands    = bands;
-  babl->pixel_format.planar   = planar;
+  babl->pixel_format.model  = model;
+  babl->pixel_format.bands  = bands;
+  babl->pixel_format.planar = planar;
 
   for (band=0; band < bands; band++)
     {
-      babl->pixel_format.model[band] = model[band];
       babl->pixel_format.component[band] = component[band];
       babl->pixel_format.type[band] = type[band];
       babl->pixel_format.sampling[band] = sampling[band];
     }
-  babl->pixel_format.model[band] = NULL;
   babl->pixel_format.component[band] = NULL;
   babl->pixel_format.type[band]      = NULL;
   babl->pixel_format.sampling[band]  = NULL;
@@ -99,14 +96,13 @@ babl_pixel_format_new (const char *name,
   int              id     = 0;
   int              planar = 0;
   int              bands  = 0;
-  BablModel       *model     [BABL_MAX_BANDS];
+  BablModel       *model  = NULL;
   BablComponent   *component [BABL_MAX_BANDS];
   BablSampling    *sampling  [BABL_MAX_BANDS];
   BablType        *type      [BABL_MAX_BANDS];
 
   BablSampling    *current_sampling = (BablSampling*) babl_sampling (1,1);
   BablType        *current_type     = (BablType*)     babl_type_id (BABL_U8);
-  BablModel       *current_model    = NULL;
   const char      *arg              = name;
 
   va_start (varg, name);
@@ -129,12 +125,11 @@ babl_pixel_format_new (const char *name,
                 current_type = (BablType*) babl;
                 break;
               case BABL_COMPONENT:
-                if (!current_model)
+                if (!model)
                   {
                     babl_log ("%s(): no model specified before component %s",
                               __FUNCTION__, babl->instance.name);
                   }
-                model     [bands] = current_model;
                 component [bands] = (BablComponent*) babl;
                 type      [bands] = current_type;
                 sampling  [bands] = current_sampling;
@@ -150,7 +145,12 @@ babl_pixel_format_new (const char *name,
                   current_sampling = (BablSampling*)arg;
                   break;
               case BABL_MODEL:
-                  current_model = (BablModel*)arg;
+                  if (model)
+                    {
+                    babl_log ("%s(%s): model %s already requested",
+                     __FUNCTION__, babl->instance.name, model->instance.name);
+                    }
+                  model = (BablModel*)arg;
                   break;
               case BABL_INSTANCE:
               case BABL_PIXEL_FORMAT:
@@ -198,9 +198,8 @@ babl_pixel_format_new (const char *name,
 
 
   babl = pixel_format_new (name, id,
-                           planar,
-                           bands,
-                           model, component, sampling, type);
+                           planar, bands, model,
+                           component, sampling, type);
 
   
   if (db_insert (babl) == babl)
index 55a16602044402973fb1cf71590b119d30c89dd1..573d11399fef7c1a7c578970c75188e80429b54e 100644 (file)
@@ -110,7 +110,7 @@ pixel_format_html (Babl *babl)
     }
   printf ("</td>");
   printf ("<td valign='top'>");
-  printf ("<span class='name'>%s</span>", BABL(babl->pixel_format.model[0])->instance.name  );
+  printf ("<span class='name'>%s</span>", BABL(babl->pixel_format.model)->instance.name  );
   printf ("</td>");
   printf ("<td>");
   for (i=0; i< babl->pixel_format.bands; i++)